package com.ssmTest.service.impl;

import com.ssmTest.dao.IJobAdDao;
import com.ssmTest.model.JobAd;
import com.ssmTest.service.IJobAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("jobAdService")
public class JobAdServiceImpl implements IJobAdService {
    @Resource
    private IJobAdDao iJobAdDao;
    @Autowired
    private IJobAdService iJobAdService;


    //根据id查找
    public JobAd selectJobAd(int id) {
        return this.iJobAdDao.selectJobAd(id);
    }

    //插入信息
    public void insertJobAd(JobAd jobAd) {
        this.iJobAdDao.insertJobAd(jobAd);
    }

    //信息列表
    public List<JobAd> JobAdList(int toexamine) {
        return this.iJobAdDao.JobAdList(toexamine);
    }

    //更新Information
    public boolean updateInformationReasion(int id, String fail_reasion) {
        if (iJobAdService.selectJobAd(id) == null)
            return false;
        this.iJobAdDao.updateInformation(id, fail_reasion);
        return true;
    }

    //更新Information
    public boolean updateJobAd(JobAd jobAd) {
        if (iJobAdService.selectJobAd(jobAd.getId()) == null)
            return false;
        this.iJobAdDao.updateJobAd(jobAd);
        return true;
    }

    //关键字查询
    public List<JobAd> selectJobAdByAndKey(int pagenum,String city,String key){
        List<JobAd> list= iJobAdDao.selectSecondByAndKey((pagenum-1)*10,pagenum*10,city,key);
        return list;
    }

    public List<JobAd> selectJobAdByNoKey(int pagenum,String city){
        List<JobAd> list= iJobAdDao.selectSecondByNoKey((pagenum-1)*10,pagenum*10,city);
        return list;
    }

    public void delJobAD(int id){
        this.iJobAdDao.delJobAD(id);
    }

    public List<JobAd> selectByPersionalId(int personal_id){
        return this.iJobAdDao.selectByPersionalId(personal_id);
    }
}
